﻿using QingZhouLinYe_Web.DbContext;
using QingZhouLinYe_Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QingZhouLinYe_Web.Ashxs
{
    /// <summary>
    /// SaveQuHua 的摘要说明
    /// </summary>
    public class SaveQuHua : IHttpHandler
    {
        private DbServices dbServices = new DbServices();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Random ran = new Random();
            QuHua qh = new QuHua();
            qh.UpId = 2;
            qh.MingCheng = "潍坊市";

            qh.CenterShape =new Location(BaseClass.RandomDouble(ran,118.60,118.65),BaseClass.RandomDouble(ran,36.60,36.65),BaseClass.RandomInt(ran,0,100));
            Location[] poits = new Location[10];
            for (int a = 0; a < 10; a++)
            {
                poits[a] = new Location(BaseClass.RandomDouble(ran,118.33, 119.45), BaseClass.RandomDouble(ran, 36.33, 36.45), BaseClass.RandomInt(ran, 0,100));
            }
            poits[9] = poits[0];
            qh.BorderShape = new Polygon(poits);
            int i = dbServices.saveQuHua(qh);
            context.Response.Write(i+"数据添加成功！");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}